function carMoves(lastLat, lastLng, currLat, currLng, map){
	var lineCoordinates = {};	
	var INI = true;
	var point = 0;
	window.setInterval(function(){
		for (var index in currLat){
//			if(INI){
//				lastLat[index] = currLat[index] - 0.002;
//				lastLng[index] = currLng[index] - 0.003;
//				point++;
//				if(point == 3)
//				INI = false;
//			}
//		else{
//			for(var index1 in lastLat){
//				lastLat[index1] = currLat[index1];
//				lastLng[index1] = currLng[index1];
//			}
//			point = point%4;
//			point++;
//			if(point == 0){
//				currLat[index] = currLat[index] - Math.random()*0.006;
//				currLng[index] = currLng[index] + Math.random()*0.008;
//			}else if(point == 1){
//				currLat[index] = currLat[index] + Math.random()*0.006;
//				currLng[index] = currLng[index] + Math.random()*0.008;
//			}else if(point == 2){
//				currLat[index] = currLat[index] + Math.random()*0.006;
//				currLng[index] = currLng[index] - Math.random()*0.008;
//			}else{
//				currLat[index] = currLat[index] - Math.random()*0.006;
//				currLng[index] = currLng[index] - Math.random()*0.008;
//			}
//				
//			}
//			console.log(index);
//			console.log(lastLat[index]);
//			console.log(lastLng[index]);
//			console.log(currLat[index]);
//			console.log(currLng[index]);
		    
			lineCoordinates[index] = [
	 									  new google.maps.LatLng(lastLat[index], lastLng[index]),
			                              new google.maps.LatLng(currLat[index], currLng[index])
			                              ];
		    lineSymbol[index] = {
					path : google.maps.SymbolPath.CIRCLE,
					scale: 3,
					strokeColor : 'red',
					strokeOpacity: 1
			};
		    
			line[index] = new google.maps.Polyline({
				path : lineCoordinates[index],
				icons : [{
					icon : lineSymbol[index],
					offset : '100%'
				}],
				strokeOpacity: 0.3,
				map : map
			});
		//	setTimeout(animateCircle(index), 20)
			animateCircle(index);
		}
	},5000)
	
}

function dealData(data){

	
	for (var index in data.dri_info){
		if(INI){
			lastLat[index] = data.dri_info[index].dri_lat;
			lastLng[index] = data.dri_info[index].dri_lng;
			PP++;
			if(PP == 4){
				INI = false;
			}
		}
		else{
			for(var index in data.dri_info){
				lastLat[index] = currLat[index];
				lastLng[index] = currLng[index];
			}
			
		}
		// get currlat and currlng array
		currLat[index] = data.dri_info[index].dri_lat;
		currLng[index] = data.dri_info[index].dri_lng;
		
		dri_id[index] = data.dri_info[index].dri_id;
		taxi_number[index] = data.dri_info[index].taxi_number;
		dri_credit[index] = data.dri_info[index].dri_credit;
		
		var icons = new google.maps.MarkerImage(
				'../images/taxi.png', new google.maps.Size(48,
						48));
		var markers = new Array();	
		
	    location1[index] = new google.maps.LatLng(currLat[index], currLng[index]);
		markers[index] = new google.maps.Marker({
			position : location1[index],
			title : 'hello',
			map : map,
			icon : icons
		});

		// add contents
	    contentString[index] = '<div id="content">'+
	      '<div id="siteNotice">'+
	      '</div>'+
	      '<h1 id="firstHeading" class="firstHeading">DriverInfo</h1>'+
	      '<div id="bodyContent">'+
	      '<p><b>dir_id: </b>' + dri_id[index] +',</b></p>'+
	      '<p><b>taxi_number: </b>' + taxi_number[index] +',</b></p>'+
	      '<p><b>dri_credit: </b>' + dri_credit[index] +',</b></p>'+
	      '</div>'+
	      '</div>';
	     infowindow[index] = new google.maps.InfoWindow({
			content: contentString[index]
		});
		google.maps.event.addListener(markers[index], 'click', function(){
			infowindow[index].open(map, markers[index])
		});
	}	
	console.log(lastLat);
	console.log(currLat);
	carMoves(lastLat, lastLng, currLat, currLng, map);
	return markers;

}

var icon1 = new google.maps.MarkerImage(
		'../images/taxi.png', new google.maps.Size(48,
					   48));
	var location1 = new google.maps.LatLng(31.195476, 121.54753);	
	 //2: show informations when CLICK the icon :
	//a:driver and customers info / hot area info
	var cus_name = "luoxuan";
	var cus_sex = "male";
	var cus_credit = "5";
	var contentString = '<div id="content">'+
      '<div id="siteNotice">'+
      '</div>'+
      '<h1 id="firstHeading" class="firstHeading">DriverInfo</h1>'+
      '<div id="bodyContent">'+
      '<p><b>Name: </b>' + cus_name +',</b></p>'+
      '<p><b>Sex: </b>' + cus_sex +',</b></p>'+
      '<p><b>Credit: </b>' + cus_credit +',</b></p>'+
      '</div>'+
      '</div>';
     var infowindow = new google.maps.InfoWindow({
          content: contentString
      });
     
	 var marker1 = new google.maps.Marker({
		position : location1,
		title : 'SEE MORE',
		map : map,
		icon : icon1,
		draggable : true
	});
	 
	 google.maps.event.addListener(marker1, 'click', function() {
    	    infowindow.open(map,marker1);
    	  });
	 
	 
	 
	var icon2 = new google.maps.MarkerImage(
			'../images/person.png', new google.maps.Size(48,
					48));						
	var location2 = new google.maps.LatLng(31.198476, 121.55753);						
	var contentString2 = '<div id="content">'+
      '<div id="siteNotice">'+
      '</div>'+
      '<h1 id="firstHeading" class="firstHeading">CusInfo</h1>'+
      '<div id="bodyContent">'+
      '<p><b>Name: </b>' + cus_name +',</b></p>/n'+
      '<p><b>Sex: </b>' + cus_sex +',</b></p>/n'+
      '<p><b>Credit: </b>' + cus_credit +',</b></p>/n'+
      '</div>'+
      '</div>';
	 var infowindow2 = new google.maps.InfoWindow({
          content: contentString2
      });
	 var marker2 = new google.maps.Marker({
			position : location2,
			title : "Hello World!",
			map : map,
			icon : icon2
		});
	 google.maps.event.addListener(marker2, 'click', function() {
    	    infowindow2.open(map,marker2);
    	  });
	 
		//TEST ADD markers
		
//		setTimeout(function(){
//			
//				for ( var i = 0; i < 50; i++) {
//					var location = new google.maps.LatLng(
//							31.195476 + Math
//									.random() * 0.08,
//							121.54753 + Math
//									.random() * 0.08);
//					var marker = new google.maps.Marker(
//							{
//								position : location,
//								title : "Hello World!",
//								map : map,
//								icon : icon1
//							});
//				}
//			
//				for ( var i = 0; i < 50; i++) {
//					var location = new google.maps.LatLng(
//							31.195476 + Math
//									.random() * 0.08,
//							121.54753 + Math
//									.random() * 0.08);
//					var marker = new google.maps.Marker(
//							{
//								position : location,
//								title : "Hello World!",
//								map : map,
//								icon : icon2
//							});
//				}
//
//
//		},1000);
	 
		
		var contentString2 = '<div id="content">'+
	    '<div id="siteNotice">'+
	    '</div>'+
	    '<h1 id="firstHeading" class="firstHeading">CusInfo</h1>'+
	    '<div id="bodyContent">'+
	    '<p><b>Name: </b>' + cus_name +',</b></p>/n'+
	    '<p><b>Sex: </b>' + cus_sex +',</b></p>/n'+
	    '<p><b>Credit: </b>' + cus_credit +',</b></p>/n'+
	    '</div>'+
	    '</div>';
		 var infowindow2 = new google.maps.InfoWindow({
	        content: contentString2
	    });
		 var marker2 = new google.maps.Marker({
				position : location2,
				title : "Hello World!",
				map : map,
				icon : icon2
			});
		 google.maps.event.addListener(marker2, 'click', function() {
	  	    infowindow2.open(map,marker2);
	  	  });
		 